package djboom.materials.display.devices {
	import djboom.materials.core.BitmapDataCore;
	import djboom.materials.display.elements.SimpleSmartSprite;

	import org.casalib.display.CasaBitmap;

	import flash.events.Event;

	/**
	 * Гирька.
	 * <br>
	 * 
	 * @author DJ BooM 
	 * @since 24.09.2010
	 * 
	 */

	public class Weight extends SimpleSmartSprite {

		// ----------------------------------------------------------------------------
		// Константы класса.
		// ----------------------------------------------------------------------------

		public static const WEIGHT_SMALL:Number = 0.2;
		public static const WEIGHT_MIDDLE:Number = 0.3;
		public static const WEIGHT_BIG:Number = 0.5;

		// ----------------------------------------------------------------------------
		// Свойства класса.
		// ----------------------------------------------------------------------------

		/**
		 * Вес гири.
		 * 
		 */

		private var _weight:Number;

		private var _weightBitmap:CasaBitmap;

		// ----------------------------------------------------------------------------
		// Конструктор.
		// ----------------------------------------------------------------------------

		public function Weight(weight:Number, bitmapDataID:String) {
			super();
			
			_weight = weight;
			
			_weightBitmap = new CasaBitmap(BitmapDataCore.getBitmapData(bitmapDataID));
			addChild(_weightBitmap);
		}	 

		// ----------------------------------------------------------------------------
		// Переопределенные методы.
		// ----------------------------------------------------------------------------

		override public function clearContent(event:Event):void {
			super.clearContent(event);
			
			if (_weightBitmap != null) {
				_weightBitmap.destroy();
				_weightBitmap = null;
			}
		}

		// ----------------------------------------------------------------------------
		// Методы доступа.
		// ----------------------------------------------------------------------------

		public function get weight():Number {
			return _weight;
		}
	}
}
